<?php

namespace Platform\Models\Video;

use Platform\Models\BaseModel;

class RedPacketVideo extends BaseModel {

    const TABLE_NAME = 'red_packet_video';

    public function initialize() {
        parent::initialize();
        $this->setSource(self::TABLE_NAME);
    }

    private $id;
    private $videoUrl;
    private $userId;
    private $type;
    private $money;
    private $img;
    private $greeting;
    private $viewCount;
    private $getPacketCount;
    private $getPacketMoney;
    private $createTime;
    private $acode;
    private $isDel;

    public function getId() {
        return $this->id;
    }

    public function getVideoUrl() {
        return $this->videoUrl;
    }

    public function getUserId() {
        return $this->userId;
    }

    public function getType() {
        return $this->type;
    }

    public function getMoney() {
        return $this->money;
    }

    public function getImg() {
        return $this->img;
    }

    public function getGreeting() {
        return $this->greeting;
    }

    public function getViewCount() {
        return $this->viewCount;
    }

    public function getGetPacketCount() {
        return $this->getPacketCount;
    }

    public function getGetPacketMoney() {
        return $this->getPacketMoney;
    }

    public function getCreateTime() {
        return $this->createTime;
    }

    public function setId($id) {
        $this->id = $id;
    }

    public function setVideoUrl($videoUrl) {
        $this->videoUrl = $videoUrl;
    }

    public function setUserId($userId) {
        $this->userId = $userId;
    }

    public function setType($type) {
        $this->type = $type;
    }

    public function setMoney($money) {
        $this->money = $money;
    }

    public function setImg($img) {
        $this->img = $img;
    }

    public function setGreeting($greeting) {
        $this->greeting = $greeting;
    }

    public function setViewCount($viewCount) {
        $this->viewCount = $viewCount;
    }

    public function setGetPacketCount($getPacketCount) {
        $this->getPacketCount = $getPacketCount;
    }

    public function setGetPacketMoney($getPacketMoney) {
        $this->getPacketMoney = $getPacketMoney;
    }

    public function setCreateTime($createTime) {
        $this->createTime = $createTime;
    }

    public function getAcode() {
        return $this->acode;
    }

    public function setAcode($acode) {
        $this->acode = $acode;
    }

    public function getIsDel() {
        return $this->isDel;
    }

    public function setIsDel($isDel) {
        $this->isDel = $isDel;
    }

    public function columnMap() {
        //列名 =》 属性名
        return [
            'id' => 'id',
            'video_url' => 'videoUrl',
            'user_id' => 'userId',
            'type' => 'type',
            'money' => 'money',
            'img' => 'img',
            'greeting' => 'greeting',
            'create_time' => 'createTime',
            'view_count' => 'viewCount',
            'get_packet_count' => 'getPacketCount',
            'get_packet_money' => 'getPacketMoney',
            "acode" => 'acode',
            "is_del" => "isDel",
        ];
    }

    /**
     * 获取一条加锁的数据的对象
     * @param $id
     * @param $columns
     */
    public function getForUpdateDataById($id, $columns = '') {
        $query = [
            "conditions" => "$this->pk = :id:",
            "bind" => [
                "id" => $id
            ],
            "for_update" => true
        ];
        if ($columns) {
            $query['columns'] = $columns;
        }
        $data = self::findFirst($query);
        return $data;
    }

}
